/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package morenoapp.components.common.table.renderer;

import java.awt.Color;
import java.awt.Component;
import java.awt.Graphics;
import java.awt.Rectangle;
import java.util.List;
import javax.swing.JTable;
import morenoapp.MorenoApp;
import morenoapp.model.data.MorenoRespondentFace;

/**
 *
 * @author root
 */
public class RespondentTooltipDefaultTableCellRenderer extends TooltipDefaultTableCellRenderer {
    private boolean drawGrayBackground = false;

    @Override
    public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
        super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
        List<MorenoRespondentFace> respondents = MorenoApp.getModel().getRespondentsList();
        if (respondents.size()>row){
            MorenoRespondentFace resp = respondents.get(row);
            setForeground(resp.getSex().getColor());
            drawGrayBackground = resp.isPassedPoll();
        } else {
            drawGrayBackground = false;
        }

        return this;
    }

//    @Override
//    public void paint(Graphics g) {
//        if (drawGrayBackground) {
//            Color backup = g.getColor();
//            g.setColor(Color.lightGray);
//            Rectangle r = getBounds();
//            for (int x = -r.height; x < r.width; x += 5) {
//                g.drawLine(x, 0, x + r.height, r.height);
//            }
//            g.setColor(backup);
//        }
//        super.paint(g);
//    }
}
